package Cn.Sarkar.MMS.Entities.Independent

import Cn.Sarkar.Entities.MMS.Additional.IThirdPartyAccount
import Cn.Sarkar.Entities.MMS.Independent.IAccount
import Cn.Sarkar.Entities.MMS.Independent.IApplication
import Cn.Sarkar.Entities.MMS.Independent.IPerson
import Cn.Sarkar.Entities.MMS.Independent.Permission.IPermissionGroup
import Cn.Sarkar.Entities.MMS.Independent.Wallet.IWallet
import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.Extensions.hasOne
import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.IDataContext
import Cn.Sarkar.MMS.DataBaseDefinations.Independent.Accounts
import Cn.Sarkar.MMS.Entities.Additional.ThirdPartyAccount
import Cn.Sarkar.Entities.Common.BaseEntity
import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.Extensions.hasOneNullable
import Cn.Sarkar.MMS.Entities.Independent.Permission.PermissionGroup
import java.util.*

class Account(DataContext: IDataContext) : BaseEntity(DataContext, Accounts), IAccount {
    var permissionID by Accounts.PermissionID
    override var permission: IPermissionGroup by hasOne(Accounts.PermissionID) { PermissionGroup(it) }
    override var applications: MutableList<IApplication> = LinkedList()
    var thirdPartyAccountID by Accounts.ThirdPartyID
    override var thirdParty: IThirdPartyAccount? by hasOneNullable(Accounts.ThirdPartyID) { ThirdPartyAccount(it) }
    override var signInName: String by Accounts.SignInName
    override var pwd: String by Accounts.Pwd
    var personID by Accounts.PersonID
    override var person: IPerson by hasOne(Accounts.PersonID) { Person(it) }
    override var wallets: MutableList<IWallet> = LinkedList()
}